package cn.zjyj.module.zjyj.dal.mysql.deviceinstance;

import cn.zjyj.framework.common.common.pojo.PageResult;
import cn.zjyj.framework.datasource.mybatis.core.query.LambdaQueryWrapperX;
import cn.zjyj.framework.datasource.mybatis.core.mapper.BaseMapperX;
import cn.zjyj.module.zjyj.dal.dataobject.deviceinstance.DeviceInstanceDO;
import org.apache.ibatis.annotations.Mapper;
import cn.zjyj.module.zjyj.controller.admin.deviceinstance.vo.*;

/**
 * 设备实例 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface DeviceInstanceMapper extends BaseMapperX<DeviceInstanceDO> {

    default PageResult<DeviceInstanceDO> selectPage(DeviceInstancePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DeviceInstanceDO>()
                .betweenIfPresent(DeviceInstanceDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(DeviceInstanceDO::getDeviceId, reqVO.getDeviceId())
                .eqIfPresent(DeviceInstanceDO::getCode, reqVO.getCode())
                .betweenIfPresent(DeviceInstanceDO::getProcurementTime, reqVO.getProcurementTime())
                .eqIfPresent(DeviceInstanceDO::getOwnerId, reqVO.getOwnerId())
                .eqIfPresent(DeviceInstanceDO::getTag, reqVO.getTag())
                .betweenIfPresent(DeviceInstanceDO::getUsageTime, reqVO.getUsageTime())
                .eqIfPresent(DeviceInstanceDO::getUnitId, reqVO.getUnitId())
                .eqIfPresent(DeviceInstanceDO::getDepartmentId, reqVO.getDepartmentId())
                .orderByDesc(DeviceInstanceDO::getId));
    }

}